// proxy 代理对象
const person = {
    name: 'tom',
    age: 12
}
const personProxy = new Proxy (person, {
    get(target, property) {
        // 内部逻辑 
        // return property in target? target[property] : default
        console.log(target, property)
        return 100
    },
    set(target, property, value) {
        if(property === 'age') {
            if(!Number.isInteger(value)) {
                throw new TypeError(`${value} is not a int`)
            }
        }
        console.log(target, property, value)
    }
})
console.log(personProxy.name)
personProxy.age = 18
personProxy.age = true


